
import org.junit.Assert;
import org.junit.Test;


public class TestUtility 
{
	@Test
	public void testStringPad()
	{
		String result = Utility.pad("Hello", 10);
		Assert.assertEquals("Hello     ", result);
	}
	
	@Test
	public void testDoublePad()
	{
		String result = Utility.pad(12345.6789, 10);
		Assert.assertEquals("0012345.68", result);
	}
	
	@Test
	public void testIntPad()
	{
		String result = Utility.pad(12, 3);
		Assert.assertEquals("012", result);		
	}
	
	// Loop and Condition Coverage
	@Test
	public void testDoublePadIfTrue()
	{
		String compare = Utility.pad(1.1, 3);
		Assert.assertEquals("1.10", compare);		
	}
	
	@Test
	public void testDoublePadIfFalse()
	{
		boolean exception = false;
		try
		{
			String compare = Utility.pad(1.1, 2);
		}
		catch (NumberFormatException ex)
		{
			exception = true;
		}
		
		Assert.assertTrue(exception);
	}
	
	@Test
	public void testDoublePadLoopZero()
	{
		String compare = Utility.pad(1.1, 3);
		Assert.assertEquals("1.10", compare);
	}
	
	@Test
	public void testDoublePadLoopOnce()
	{
		String compare = Utility.pad(1.1, 4);
		Assert.assertEquals("1.10", compare);
	}
	
	@Test
	public void testDoublePadLoopMany()
	{
		String compare = Utility.pad(1.1, 6);
		Assert.assertEquals("001.10", compare);
	}
}
